package cn.jhc.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.dbutils.QueryRunner;

import cn.jhc.bean.Article;
import cn.jhc.bean.User;
import cn.jhc.db.ArticleDao;
import cn.jhc.db.UserDao;

/**
 * Servlet implementation class DeleteBolg
 */
@WebServlet("/del.do")
public class DeleteServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String idStr =request.getParameter("id");
		System.out.println(idStr );
		int id = Integer.parseInt(idStr);
		
	QueryRunner runner = (QueryRunner) request.getServletContext().getAttribute("runner");
		ArticleDao.del(runner, id);
		request.getRequestDispatcher("./list.do").forward(request, response);
		response.sendRedirect("./list.do");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
